package com.fyzk.activity.lottery.jc.football.newJz.data;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.tyjc.lottery.R;

import java.util.ArrayList;

/**
 * Created by fanxs11 on 16/5/3.
 *
 * 数据分析
 */
public class AnalysisView extends LinearLayout {

    private Context context;
    private QQListView listView;
    private ArrayList<AnalysisViewInfo> infos = new ArrayList<>();
    private AnalysisAdapter adapter;

//    private JCZQ_AnalyzeResponse analyzeResponse;

    public AnalysisView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        this.context = context;

        //临时数据
//        AnalysisViewInfo info = new AnalysisViewInfo();
//        info.group = "心水推荐";
//        info.view = new RankingView(context);
//        infos.add(info);
        AnalysisViewInfo info2 = new AnalysisViewInfo();
        info2.icon = R.drawable.jczq_analysis_lishi;
        info2.group = "历史交锋";
        info2.type = 0;
        info2.view = new AnalysisHistoryView(context);
//        for (int i = 0; i < 10; i++) {
//            AnalysisChildInfo childInfo = new AnalysisChildInfo();
//            childInfo.event = "赛事"+i;
//            info2.childInfos.add(childInfo);
//        }
        infos.add(info2);
        AnalysisViewInfo info3 = new AnalysisViewInfo();
        info3.icon = R.drawable.jczq_analysis_jinqi;
        info3.group = "近期战绩";
        info3.type = 1;
        info3.view = new AnalysisRecentView(context);
//        for (int i = 0; i < 20; i++) {
//            AnalysisChildInfo childInfo = new AnalysisChildInfo();
//            childInfo.event = "赛事"+i;
//            info3.childInfos.add(childInfo);
//        }
        infos.add(info3);
        AnalysisViewInfo info4 = new AnalysisViewInfo();
        info4.icon = R.drawable.jczq_analysis_weilai;
        info4.group = "未来比赛";
        info4.type = 2;
        info4.view = new AnalysisFutureView(context);
//        for (int i = 0; i < 10; i++) {
//            AnalysisChildInfo childInfo = new AnalysisChildInfo();
//            childInfo.event = "赛事"+i;
//            info4.childInfos.add(childInfo);
//        }
        infos.add(info4);

        initView();
    }

    public AnalysisView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public AnalysisView(Context context) {
        this(context, null);
    }

    public void initView(){
        View.inflate(context, R.layout.jc_analysis_view, this);
        listView = (QQListView) findViewById(R.id.jc_analysis_listview);
        listView.setGroupIndicator(null);
        listView.clearChoices();
        listView.setDividerHeight(0);
        listView.setHeaderView(LayoutInflater.from(context).inflate(R.layout.qqlist_group, null));
        adapter = new AnalysisAdapter(context, infos, listView);
        listView.setAdapter(adapter);

        for(int i = 0; i < adapter.getGroupCount(); i++){
            listView.expandGroup(i);
        }
    }

    public void changeData(){
        infos.get(0).view = new AnalysisHistoryView(context);
        infos.get(1).view = new AnalysisRecentView(context);
        infos.get(2).view = new AnalysisFutureView(context);
        adapter.notifyDataSetChanged();
    }

}
